<?php

class GetStage
{
	private $sugar_client;
	private $wsdl;
	
	/* Constructor */
	public function __Construct($arg_wsdl)
	{
		$this->wsdl = $arg_wsdl;
		$this->sugar_client = new nusoapclient($arg_wsdl, true);
	}
	
	/* Geef een array van alle bedrijven terug */
	public function getStages()
	{
		$session_id = $_SESSION['session'];
		$set_entry_params = array(
								  'session' => $session_id,
								  'module_name' => 'st_Stage',
								  'query' => '',
								  'order_by' => '',
								  'select_fields'=>array(
															'id',
															'fromd',
															'tilld',
															'student1',
															'student2',
															'bedrijf_id',
															'docent_id',
															'stagetype',
															'status'
														),
								  'deleted' => false
								  );
		
		//Parse de "ruwe" data naar objecten en geef deze vervolgens terug
		$parser = new Parser($this->wsdl);
		$parser->setResult($this->sugar_client->call('get_entry_list',$set_entry_params));
		
		return $parser->getStageArray();
	}
	
	public function getStage($arg_stage_id)
	{
		$session_id = $_SESSION['session'];
		$set_entry_params = array(
								  'session' => $session_id,
								  'module_name' => 'st_Stage',
								  'id' => $arg_stage_id,
								  'select_fields'=>array(
															'id',
															'fromd',
															'tilld',
															'student1',
															'student2',
															'bedrijf_id',
															'docent_id',
															'stagetype',
															'status'
														)
								  );
		
		//Parse de "ruwe" data naar objecten en geef deze vervolgens terug
		$parser = new Parser($this->wsdl);
		$result = $this->sugar_client->call('get_entry',$set_entry_params);
		
		$parser->setResult($result);
		
		$stage = $parser->getStageArray();
		return $stage[0];
	}
}

?>
